
* REPLICATION COMMANDS FOR: Is Gerrymandering Poisoning the Well of Democracy? Evaluating the Relationship between Redistricting and Citizens’ Attitudes

* Authors: Ryan D. Williamson; Florian Justwan

* All calculations were performed in STATA v.14.

* install the command mplotoffset
ssc install mplotoffset 

* set Stata color scheme
set scheme s1mono

* ###########FIGURE 3######
reg map_legitimacy b1.treatment i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment<3 & inattentive!=1
margins, at(treatment=(1 2))
marginsplot, title (Figure 3: Perceived Map Legitimacy by Treatment Group) xtitle("Treatment Group") xscale(range(.5 2.5)) xlabel(1 "Square Map" 2 "Distorted Map")ytitle(Perceived Map Legitimacy) plotopts(connect(none)) 

*###########FIGURE 4######
ologit advantage_combined b3.treatment##i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment>2 & inattentive!=1
margins, at(pid=(1 2 3) treatment=(3 4 5)) expression(predict(outcome(3)) + predict(outcome(4)))
mplotoffset, title (Figure 4: Predicted Probability of Perceived Gerrymandering) xtitle("Party ID") xscale(range(.5 3.5)) xlabel(1 "Democrats" 2 "Independents" 3 "Republicans")legend(order(4 "Independent Commission" 5 "DEM State Legislature" 6 "REP State Legislature")position(6)) ytitle(Probability of DV = 3 or 4) plotopts(connect(none)) yline(0) offset(0.20)

*###########FIGURE 5######
reg map_legitimacy b3.treatment##i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment>2 & inattentive!=1
margins, at(pid=(1 2 3) treatment=(3 4 5))
mplotoffset, title (Figure 5: Perceived Map Legitimacy by Party ID) xtitle("Party ID") xscale(range(.5 3.5)) xlabel(1 "Democrats" 2 "Independents" 3 "Republicans")legend(order(4 "Independent Commission" 5 "DEM State Legislature" 6 "REP State Legislature")position(6)) ytitle(Perceived Map Legitimacy) plotopts(connect(none)) offset(0.20)

*###########FIGURE 6######
reg map_legitimacy b3.treatment##c.comms_better i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment>2 & inattentive!=1
margins, dydx(treatment) at(comm=(1 2 3 4 5))
mplotoffset, title (Panel A: By Perceived Fairness of Commissions) xtitle("Perceived Fairness of Commissions") xscale(range(.5 5.5)) legend(order(3 "DEM State Legislature" 4 "REP State Legislature")position(6)) ytitle(Marginal Effect on Perceived Map Legitimacy) plotopts(connect(none)) yline(0) offset(0.25) saving(Fig6A.gph)

reg map_legitimacy b3.treatment##c.gerr_concerns i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment>2 & inattentive!=1
margins, dydx(treatment) at(gerr=(-3.2 (.5) 1.4))
mplotoffset, title (Panel B: By Perceived Gerrymandering Threat) xtitle("Perceived Threat of Gerrymandering") xscale(range(-3.5 1.5)) legend(order(3 "DEM State Legislature" 4 "REP State Legislature")position(6)) ytitle(Marginal Effect on Perceived Map Legitimacy) plotopts(connect(none)) yline(0) offset(0.15) saving(Fig6B.gph)

graph combine Fig6A.gph Fig6B.gph, ycommon title(Figure 6: Marginal Effect of Legislature-Led Redistricting) iscale(.5) row(1)



*###########REGRESSION MODELS############################

*Model 1.1: 
ologit satisfied_dem_us satisfied_lines_state i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if inattentive!=1
margins, at(satisfied_lines_state=(1(1)4)) expression(predict(outcome(3)) + predict(outcome(4)))

*Model 1.2: 
ologit advantage_combined b1.treatment i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment<3 & inattentive!=1

*Model 1.3: 
reg map_legitimacy b1.treatment i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment<3 & inattentive!=1

*Model 1.4: 
reg map_legitimacy b1.treatment##i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment<3 & inattentive!=1

*Model 1.5: 
ologit advantage_combined b3.treatment##i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment>1 & inattentive!=1

*Model 1.6: 
reg map_legitimacy b3.treatment##i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment>1 & inattentive!=1

*Model 1.7: 
reg map_legitimacy b3.treatment##c.comms_better i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment>1 & inattentive!=1

*Model 1.8: 
reg map_legitimacy b3.treatment##c.gerr_concerns i.pid3 age female edu income ideo7 white latin news_consumption knowledge_scale interest if treatment>1 & inattentive!=1




*###########Construction of "Threat from Gerrymandering"-Variable######
factor lose_fair_rep lose_choice lose_attention pols_choose_voters, pcf
scree

*###########Construction of "Perceived Map Legitimacy"-Variable######
factor fair_combined choice_combined listen_combined, pcf
scree
